import pick from 'lodash.pick'

export default {
    data() {
        return {
            labelCol: {
                xs: {
                    span: 24
                },
                sm: {
                    span: 7
                },
            },
            wrapperCol: {
                xs: {
                    span: 24
                },
                sm: {
                    span: 10
                },
            },
            submitLoading: false,
            form: this.$form.createForm(this),
            organizationTree: [],
        }
    },
    methods: {
        // 新增
        add(arg) {
            console.log(arg);
        },
        // 编辑--form赋值
        update(data) {
            // 延迟加载 避免隐藏展示元素时出现的bug
            setTimeout(() => {
                const fromData = pick(data, Object.keys(this.form.getFieldsValue()))
                this.$nextTick(function () {
                    this.form.resetFields();
                    this.form.setFieldsValue(fromData);
                    console.log(this.form.getFieldsValue(), 'form')
                });
            }, 0);
        },
    }
}